﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Utils
{
    public class ColorUtil
    {
        /// <summary>
        /// 获取元素所对应的颜色
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public static Color GetElementColor(Element element)
        {
            //根据元素属性显示背景色
            Color backgroudColor;
            switch (element)
            {
                case Element.Fire:
                    backgroudColor = new Color(255 / 255.0f, 69 / 255.0f, 0); //橘红
                    break;
                case Element.Ice:
                    backgroudColor = new Color(0, 191 / 255.0f, 255 / 255.0f);//深天蓝
                    break;
                case Element.Wind:
                    backgroudColor = new Color(152 / 255.0f, 251 / 255.0f, 152 / 255.0f);//弱绿
                    break;
                case Element.Geo:
                    backgroudColor = new Color(184 / 255.0f, 134 / 255.0f, 11 / 255.0f);//暗金菊黄
                    break;
                case Element.Light:
                    backgroudColor = new Color(255 / 255.0f, 255 / 255.0f, 224 / 255.0f); //浅黄色
                    break;
                case Element.Dark:
                    backgroudColor = new Color(128 / 255.0f, 0, 128 / 255.0f); //紫色
                    break;
                default:
                    backgroudColor = new Color(192 / 255.0f, 192 / 255.0f, 192 / 255.0f);//银色
                    break;
            }

            return backgroudColor;
        }

        /// <summary>
        /// 可用
        /// </summary>
        static readonly Color availableColor = new Color(173 / 255.0f, 1, 47 / 255.0f);
        /// <summary>
        /// 不可用
        /// </summary>
        static readonly Color unavailableColor = new(219 / 255.0f, 219 / 255.0f, 219 / 255.0f);
        /// <summary>
        /// 获取状态色
        /// </summary>
        /// <param name="available"></param>
        /// <returns></returns>
        public static Color GetStateColor(bool available)
        {
            if(available) return availableColor;
            else return unavailableColor;
        }
    }
}
